# -*- coding: utf-8 -*-

from django.conf.urls.defaults import *

# Uncomment the next two lines to enable the admin:
from django.contrib import admin
import settings
import views
admin.autodiscover()

from django.http import HttpResponse, HttpResponseRedirect

def get_redirect_function_to_url(url):
    ''' Create response object which redirects client to given url. '''
    return (lambda request: HttpResponseRedirect(url))

urlpatterns = patterns('',
    (r'^$', get_redirect_function_to_url('/entelib/')),
    (r'^entelib/$', views.login),
    (r'^entelib/logout/$', views.logout),
    # Example:
    # (r'^entelib/', include('entelib.foo.urls')),

    # Uncomment the admin/doc line below and add 'django.contrib.admindocs' 
    # to INSTALLED_APPS to enable admin documentation:
    # (r'^admin/doc/', include('django.contrib.admindocs.urls')),

    # Uncomment the next line to enable the admin:
    (r'^entelib/admin/', include(admin.site.urls)),
    (r'^admin/', get_redirect_function_to_url('/entelib/admin/')),
    (r'^entelib/book/', views.book),
    (r'^' + settings.MEDIA_URL[1:] + '(?P<path>.*)$',  'django.views.static.serve', 
        {'document_root': settings.MEDIA_ROOT,}),
)
